# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=libmodsecurity
pkgver=3.0.9
pkgrel=3
epoch=1

pkgdesc='ModSecurity v3 library component'
arch=('loong64' 'x86_64')
depends=('yajl' 'curl' 'lmdb' 'libxml2' 'pcre2' 'geoip' 'libmaxminddb' 'ssdeep' 'luajit')
makedepends=('doxygen')
url="https://github.com/SpiderLabs/ModSecurity/tree/v3/master"
license=('APACHE')
source=("https://github.com/SpiderLabs/ModSecurity/releases/download/v$pkgver/modsecurity-v$pkgver.tar.gz"{,.asc})
sha256sums=('a5111ecd23e332a1d7c9652dbdb18517a96b21573315cb887a8e86761b95d3d8'
            'SKIP')
validpgpkeys=('190EFACCA1E9FA466A8ECD9CE6DFB08CE8B11277'  # Felipe Zimmerle da Nobrega Costa <felipe@zimmerle.org>
              'F126692E9BA86B3958E73ED2F2FC4E45883BCBA4') # Martin Vierula (GitHub key) <Martin.Vierula@trustwave.com>

build() {
	cd "$srcdir"/modsecurity-v$pkgver
	sed -e 's/luajit-2.0/luajit-2.1/g' \
		-e 's/LUA_POSSIBLE_LIB_NAMES="/LUA_POSSIBLE_LIB_NAMES="luajit /g' \
		-i build/lua.m4
	./build.sh
	./configure \
		--prefix=/usr \
		--with-lmdb \
		--with-libxml \
		--with-lua \
		--with-pcre2 \
		--with-ssdeep \
		--disable-examples
	sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
	make
}

package() {
	cd "$srcdir"/modsecurity-v$pkgver
	make DESTDIR="$pkgdir" install
}
